package ui.create_group

import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.mutableStateOf
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import model.repository.ChannelMappingRepository
import model.vo.FriendsMappingItem
import ui.home.HomeViewModel


/**
 * @author wei kunJie
 * @date 2024/4/24 15:20:34
 */
class CreateGroupViewModel(coroutineScope: CoroutineScope) {
    var coroutineScope: CoroutineScope

    //搜索关键字
    val searchKeyWord = mutableStateOf("")

    //好友列表
    val friendList = mutableStateListOf<FriendsMappingItem>()

    //选中的人的列表
    val choseFriendList = mutableStateListOf<FriendsMappingItem>()
    val choseFriendMap = mutableMapOf<String, FriendsMappingItem>()
    val createClickEnable = mutableStateOf(true)
    val isShow = mutableStateOf(true)

    init {
        this.coroutineScope = coroutineScope
    }

    fun createGroup(homeViewModel: HomeViewModel) {
        coroutineScope.launch(Dispatchers.IO,) {
            ChannelMappingRepository.createGroup(this@CreateGroupViewModel,homeViewModel)
        }
    }


}